<?php include template('header','common');?>
<link rel="stylesheet" type="text/css" href="{__ROOT__}template/default/statics/css/jiaofei.css?v={HD_VERSION}">
<script type="text/javascript" src="{__ROOT__}statics/js/haidao.validate.js?v={HD_VERSION}"></script>
<div class="container">
	<div class="content">
		<div class="item">
			<div class="top">
				<img src="{$schoolData['logo']}" alt="">
				<div class="top-content">
					<span>{$schoolData['name']}午托班</span>					
				</div>
				<span class="top-price"><?php echo intval($schoolData['months_price']);?>元/天</span>
			</div>
			<div class="bottom">
				<span class="bottom-title">
					已加入的家长
					<i>({$schoolData['count']}/{$schoolData['number']})</i>
				</span>
				<div class="bottom-img">
					<?php foreach($schoolData['deps'] as $k => $v){?>
					<div>
						<img src="{$v['avatar']}" alt="">
					</div>
					<?php }?>
				</div>
			</div>
            {if $schoolData['class_id'] == 0}
            <img class="sign" src="{__ROOT__}template/default/statics/img/faqi.png" alt="">
            {else}
            <img class="sign" src="{__ROOT__}template/default/statics/img/kaiban.png" alt="">
            {/if}			
		</div>
	</div>
	<form class="padding-small" method="post" action='{url("post",array("formhash"=>FORMHASH))}' name="postPay">
	<div class="pay-content">
		<div class="btn">
			<div class="tishi" >
				<img src="{SKIN_PATH}statics/img/ti-shi-.png" alt="">恭喜您，本校午托班有学位。现在缴费，系统将为您锁定学位并从<font class="start_time">{$inTime[1][0]}</font>开始计费，请孩子在该日期加入午托班。获取午托地址和联系老师请在完成缴费后进入“托班圈”。
			</div>
		</div>
		<div class="btn-view" style="position:fixed; bottom:95px;">
			{if $inTime[2][3] > 0}
			<button type="button" class="payType btn1" start_time="{$inTime[2][0]}" end_time="{$inTime[2][1]}" number="{$inTime[2][2]}" price="{$inTime[2][3]}" payType="0" day="{$day}">本月</button>
			{else}
			<button type="button" class="btn3">本月</button>
			{/if}
            {if $inTime[1][3] > 0}
			<button type="button" class="payType btn1" start_time="{$inTime[1][0]}" end_time="{$inTime[1][1]}" number="{$inTime[1][2]}" price="{$inTime[1][3]}" payType="1" day="3">下个月</button>
            {else}
			<button type="button" class="btn3">下个月</button>
			{/if}
			{if $inTime[3][3] > 0}
			<button type="button" class="payType btn1" start_time="{$inTime[3][0]}" end_time="{$inTime[3][1]}" number="{$inTime[3][2]}" price="{$inTime[3][3]}" payType="3" day="{$day}">本学期</button>
			{else}
			<button type="button" class="btn3">本学期</button>
			{/if}
            {if $inTime[0][3] > 0}
			<button type="button" class="payType btn1" start_time="{$inTime[0][0]}" end_time="{$inTime[0][1]}" number="{$inTime[0][2]}" price="{$inTime[0][3]}" payType="2" day="3">下学期</button>
            {else}
			<button type="button" class="btn3">下学期</button>
			{/if}
		</div>
		<div class="rideo" style="position:fixed; bottom:95px;">
			<img class="tonyi" src="{__ROOT__}template/default/statics/img/shi.png" alt="">
			<span style="margin-left:5px;">我已阅读并同意<a href='{url("protocol",array("school_id"=>$schoolData[id],"formhash"=>FORMHASH))}' style="color:#88ba03;text-decoration:underline;">《安昕午托须知》</a></span>
		</div>
		<div class="pay-list" style="position:fixed; bottom:49px;">
			<span style="background:#ddd;" onclick="_system._guide(true)">邀请有礼</span>
			<span>￥<font class="price">{$inTime[1][3]}</font></span>
			<span class="pay-btn">立即付款</span>
		</div>
	</div>
	<input type="hidden" name="start_time" value="{$inTime[1][0]}" />
	<input type="hidden" name="end_time" value="{$inTime[1][1]}" />
	<input type="hidden" name="price" value="{$inTime[1][3]}" />
	<input type="hidden" name="iid" value="{$initiate['id']}" />
	<input type="hidden" name="sid" value="{$sid}" />
	<input type="hidden" name="payType" value="1" />
	</form>
</div>

<?php include template('footer','common');?>
<script>
var payType = $(".payType").eq(0);
payType.removeClass('btn1').addClass('btn2');
$("[name='start_time']").val(payType.attr('start_time'));
$("[name='end_time']").val(payType.attr('end_time'));
$("[name='price']").val(payType.attr('price'));
$("[name='payType']").val(payType.attr('payType'));
$(".price").text(payType.attr('price'));
$(".start_time").text(payType.attr('start_time'));
$(".day").text(payType.attr('day'));
	
$(".payType").click(function(){
	$(".payType").removeClass('btn2').addClass('btn1');
	$(this).removeClass('btn1').addClass('btn2');
	$("[name='start_time']").val($(this).attr('start_time'));
	$("[name='end_time']").val($(this).attr('end_time'));
	$("[name='price']").val($(this).attr('price'));
	$("[name='payType']").val($(this).attr('payType'));
	$(".price").text($(this).attr('price'));
	$(".start_time").text($(this).attr('start_time'));
	$(".day").text($(this).attr('day'));
});

$(".pay-btn").click(function(){
	if($(".rideo").find('img').attr("src")=="{__ROOT__}template/default/statics/img/fou.png"){
		alerts("同意《安昕午托须知》才能够付款哦~");return false;
	}
	var ajaxurl="<?php echo url('order/order/create')?>";
	var start_time = $("[name='start_time']").val();
	var end_time = $("[name='end_time']").val();
	var price = $("[name='price']").val();
	var iid = $("[name='iid']").val();
	var sid = $("[name='sid']").val();
	var payType = $("[name='payType']").val();
	var _this = $(this);
	_this.text('提交中...');
	$.post(ajaxurl,{'start_time':start_time,'end_time':end_time,'price':price,'iid':iid,'sid':sid,'payType':payType},function(ret){
		if(ret.status == 1){
			_this.text('立即付款');
			window.location.href=ret.referer;
		}else{
			_this.text('立即付款');
			alerts(ret.message);
		}
	},'json');
});
$(".rideo").click(function(){
	if($(this).find('img').attr("src")=="{__ROOT__}template/default/statics/img/fou.png"){
		$(this).find('img').attr("src","{__ROOT__}template/default/statics/img/shi.png")
	}else{
		$(this).find('img').attr("src","{__ROOT__}template/default/statics/img/fou.png")
	}
});
</script>